package cn.lyf.controller;

import cn.lyf.entity.BlogType;
import cn.lyf.respjson.RespJson;
import cn.lyf.service.BlogTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/api/adm")
public class AdmController {
    @Autowired
    BlogTypeService blogTypeService;

    @RequestMapping("/go2AddBlogType")
    public String go2AddBlogType(){
        return "adm/addBlogType";
    }

    @RequestMapping("/addBlogType")
    @ResponseBody
    public Map<String,Object> addBlogType(@RequestBody BlogType blogType){
        blogType.setNum(0);//博客类别里面的博客数量初始化为0
        blogTypeService.add(blogType);
        return RespJson.pack(200,"添加成功",null);
    }

}
